import { Module } from '@nestjs/common'
import { TypeOrmModule } from '@nestjs/typeorm'
import { PassportModule } from '@nestjs/passport'
import { JwtModule } from '@nestjs/jwt'

import { AuthController } from './auth.controller'
import { AuthService } from './auth.service'
import { AuthEntity, UserEntity, RoleEntity } from '../../entitys'
import { LocalStrategy } from './strategies/local.strategy'
import { JwtStrategy } from './strategies/jwt.strategy'

@Module({
  imports: [
    TypeOrmModule.forFeature([AuthEntity, UserEntity, RoleEntity]),
    PassportModule,
    JwtModule.register({
      secret: process.env.SECRET, // 私钥
      signOptions: { expiresIn: process.env.__DEV__ ? '30d' : '2h' } // 过期时间
    })
  ],
  controllers: [AuthController],
  providers: [AuthService, LocalStrategy, JwtStrategy]
})
export class AuthModule {}
